package stock.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class TestController {
    @GetMapping("/test")
    public String test(){
        return "服务提供测试正常";
    }

    @Autowired
    //必须在使用RestTemplate的Bean注解后加上负载均衡注解 --在Main里面加了
    private RestTemplate restTemplate;

    @GetMapping(path = "/get/stock")
    public String getStock(){

//        Map map = JSON.parseObject(restTemplate.getForObject("http://cloud-stock/nacos/get/config", String.class));
        String a = restTemplate.getForObject("http://cloud-stock-customer/test", String.class);
        return "我获取了stock服务的数据："+a;
    }
}
